import instance from "@/utils/instance";


function uploadSingle(formData, callback) {
  return instance.post("upload_single", formData, {
    headers: { "Content-Type": "multipart/form-data" },
    onUploadProgress(e) {
      callback && callback(e)
    },
  });
}

function uploadSingleBase64(param) {
  return instance.post("upload_single_base64", param);
}

function uploadSingleName(param) {
  return instance.post("upload_single_name", param, {
    headers: { "Content-Type": "multipart/form-data" },
  });
}

function uploadAlready(hash) {
  return instance.get(`upload_already?HASH=${hash}`, {
    headers: { "Content-Type": "multipart/form-data" },
  });
}

function uploadChunk(param) {
  return instance.post("upload_chunk", param, {
    headers: { "Content-Type": "multipart/form-data" },
  });
}

function uploadMerge(param) {
  return instance.post("upload_merge", param);
}


export default {
  uploadSingle,
  uploadSingleBase64,
  uploadSingleName,
  uploadAlready,
  uploadChunk,
  uploadMerge
};
